#!/usr/bin/python2
# encoding=utf-8
from SshClient import SshClient
'''
        'sudo mkdir /var/lib/mongodb_26',
        'sudo mv /var/lib/mongodb/* /var/lib/mongodb_26',
        'sudo mv /etc/mongod.conf /etc/mongod.bak',
        'sudo service mongodb stop',
        'sudo apt-get purge mongodb-org* -y',
        'sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv EA312927',
        'echo "deb http://repo.mongodb.org/apt/ubuntu trusty/mongodb-org/3.2 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-3.2.list',
        'sudo apt-get update',
        'sudo apt-get install -y mongodb-org',
        'sudo sed -i "s/#  engine/  engine: wiredTiger/g" /etc/mongod.conf',
        'sudo sed -i "s/bindIp: 127.0.0.1/bindIp: 0.0.0.0/g" /etc/mongod.conf',
'''
if __name__ == '__main__':
    cmd = [
        'cd ~/',
        'mkdir dump',
        'cd dump'
    ]
    ip = "120.26.214.10"
    username = "root"
    passwd = "Bbxvip123456"
    print "Begin......"
    client = SshClient(host=ip, port=22, username=username, password=passwd)
    try:
        for m in cmd:
            ret = client.sexecute(m)
            print ret
        print '%s\tOK\n' % (ip)
    except Exception, ex:
        print ex
        print '%s\tError\n' % (ip)
    client.close()
